package com.rio.dandan.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import com.rio.dandan.util.SessionUtils;

/**
 * 
 * SessionFilter.java
 * 
 * @author 宋陆
 * @version 1.0 2014-5-19
 */
public class SessionFilter implements Filter {
    /**
     * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
     */
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        try {
            SessionUtils.buildContext(request);
            chain.doFilter(request, response);
        } finally {
            SessionUtils.clear();
        }
    }

    /**
     * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
     */
    public void init(FilterConfig config) throws ServletException {

    }

    /**
     * @see javax.servlet.Filter#destroy()
     */
    public void destroy() {

    }
}
